//
//  MZLoginCell.m
//  明和智能
//
//  Created by innofive on 2018/4/12.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "MZLoginCell.h"
#import "NSString+Tools.h"
#import "UIView+Base.h"



@implementation MZLoginCell0
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(NSDictionary *)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.backgroundColor = [UIColor clearColor];
}

@end

@interface MZLoginCell()
@property(nonatomic,strong)UIView *v;
@property(nonatomic,strong)UITextField *textF;
@end


@implementation MZLoginCell
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(NSDictionary *)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.backgroundColor = [UIColor clearColor];
   
    UIView *v = ({
        UIView *l = [UIView new];
        l.backgroundColor = [UIColor whiteColor];
        [view addV:l];
        l;
    });
    v.hasTopLine = YES;
    v.hasBottomLine = YES;
    v.hasLeftLine = YES;
    v.hasRightLine = YES;
    
    self.v= v;
    
    UITextField *textF = ({
        UITextField *l = [[UITextField alloc]init];
        //l.backgroundColor = [UIColor redColor];
        l.leftImageName =dataSource[@"leftImageName"];
        l.placeholder =dataSource[@"placeholder"];
        l.placeholderFont = kSysFont(kFitW(14));
        [v addV:l];
        l;
    });
    self.textF= textF;
    
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        v.frame = CGRectMake(kFitW(10),0, size.width-2*kFitW(10),size.height);
        textF.frame = CGRectMake(0, kFitH(5),v.width, size.height-kFitH(5));
    }];
    
}

@end


@implementation MZLoginCell1
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(NSDictionary *)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    
    
    [super onAsInitAddView:view forViewController:ViewController forDataSource:dataSource AtIndexPath:indexPath];

    self.v.hasTopLine = NO;
    
//    UIView *lin = ({
//        UIView *l = [UIView new];
//        l.backgroundColor =hexCOLOR(@"#dbdbdb");
//        [self.v addV:l];
//        l;
//    });
    
    WSELF(weakSelf);
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {

        weakSelf.v.frame = CGRectMake(kFitW(10),0, size.width-2*kFitW(10),size.height);
        weakSelf.textF.frame = CGRectMake(0,0,weakSelf.v.width, size.height);
       // lin.frame = CGRectMake(0, 0, weakSelf.v.width,0.5);
    }];
    
    
}

@end




@implementation MZLoginCell2
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(NSDictionary *)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.backgroundColor = [UIColor clearColor];
    
    UIButton *v = ({
        UIButton *l = [UIButton buttonWithType:UIButtonTypeCustom];
        [l setNormalTitle:dataSource[@"placeholder"]];
        
        l.backgroundColor = hexCOLOR(@"FFA535");
        l.cornerRadius = kFitH(5);
        l.masksToBounds = YES;
        l.tag = 100;
        [l AddTarget:ViewController Action:@selector(onClickButton:)];
//        [l setNormalBackImage:IMAGE(@"")];
        [view addV:l];
        l;
    });
    
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        v.frame = CGRectMake(kFitW(10),kFitH(25), size.width-2*kFitW(10),size.height-kFitH(25));
    }];
    
}

@end






@implementation MZLoginCell3
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(NSDictionary *)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    self.backgroundColor = [UIColor clearColor];
    
    UIButton *v = ({
        UIButton *l = [UIButton buttonWithType:UIButtonTypeCustom];
        [l setNormalTitle:@"忘记密码?"];
        [l setNormalTitleColor:hexCOLOR(@"FFA535")];
        l.titleLabel.font = kSysFont(kFitH(14));
        l.tag =200;
        [l AddTarget:ViewController Action:@selector(onClickButton:)];
        //        [l setNormalBackImage:IMAGE(@"")];
        [view addV:l];
        l;
    });
    
    UIButton *v1 = ({
        UIButton *l = [UIButton buttonWithType:UIButtonTypeCustom];
        [l setNormalTitle:@"马上注册"];
        [l setNormalTitleColor:hexCOLOR(@"FFA535")];
        l.titleLabel.font = kSysFont(kFitH(14));
        l.tag =300;
        [l AddTarget:ViewController Action:@selector(onClickButton:)];
        //        [l setNormalBackImage:IMAGE(@"")];
        [view addV:l];
        l;
    });
    
    CGFloat w = [NSString calculateLabelWidth:@"忘记密码?" font:kSysFont(kFitH(14)) AndHeight:CGFLOAT_MAX];
    CGFloat w1 = [NSString calculateLabelWidth:@"马上注册" font:kSysFont(kFitH(14)) AndHeight:CGFLOAT_MAX];
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        
        
        v.frame = CGRectMake(kFitW(30),kFitH(20),w,size.height-kFitH(20));
        
        v1.frame = CGRectMake(size.width-kFitW(30)-w1,kFitH(20),w1,size.height-kFitH(20));
    }];
    
}

@end


@implementation MZLoginCell4
-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forDataSource:(NSDictionary *)dataSource AtIndexPath:(NSIndexPath *)indexPath
{
    
    
    [super onAsInitAddView:view forViewController:ViewController forDataSource:dataSource AtIndexPath:indexPath];
    
    self.v.hasTopLine = NO;
    NSString *btnImage =dataSource[@"btnImage"];
    NSString *btnTitle =dataSource[@"btnTitle"];
    UIButton *v1 = ({
        UIButton *l = [UIButton buttonWithType:UIButtonTypeCustom];
        if (kStringIsEmpty(btnImage)==NO) {
        [l setNormalImage:[UIImage imageNamed:btnImage]];
        }
        if (kStringIsEmpty(btnTitle)==NO) {
            [l setNormalTitle:btnTitle];
        }
        [l setNormalTitleColor:hexCOLOR(@"FFA535")];
        l.titleLabel.font = kSysFont(kFitH(14));
        l.tag =indexPath.row+100;
        [l AddTarget:ViewController Action:@selector(onClickButton:)];
        //        [l setNormalBackImage:IMAGE(@"")];
        [self.v addV:l];
        l;
    });
    
    WSELF(weakSelf);
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        
        weakSelf.v.frame = CGRectMake(kFitW(10),0, size.width-2*kFitW(10),size.height);
        weakSelf.textF.frame = CGRectMake(0,0,weakSelf.v.width, size.height);
        [v1 sizeToFit];
        v1.centerY = size.height/2;
        v1.right =weakSelf.v.width-kFitW(10);
        
        // lin.frame = CGRectMake(0, 0, weakSelf.v.width,0.5);
    }];
    
    
}
@end

